import ApiUtil from "@/utils/ApiUtil.ts";

export const getContainerInfo = async () => {
    return await ApiUtil.get<{data: [{name: string, size: number}]}>('/api/photo/info/')
}

import axios from 'axios'

const req = axios.create({
})

interface BaseRes<T> {
    success: boolean,
    data: T,
    msg: string
}

export const getPhotoFromServer = async (containerIndex?: number, index?: number) => {
    let url = '/api/photo'
    if (containerIndex != null) {
        url = url + '/' + containerIndex
        if (index != null) {
            url = url + '/' + index
        }
    }
    return await req.get<Blob>(url, {responseType: 'blob'}).then((response) => {
        return response.data
    })
}

export const getPhotoInfo = async () => {
    return await req.get<BaseRes<[{name: string, size: number}]>>('/api/photo/info').then((response) => {
        return response.data.data
    })
}